package com.ylfstu.set_;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class SetMethod {
    @SuppressWarnings({"all"})
    public static void main(String[] args) {
        Set set = new HashSet();
        set.add("john");
        set.add("lucy");
        set.add("john");
        set.add("jack");
        set.add("ylf");
        set.add("lily");
        set.add(null);
        set.add(null);

        System.out.println(set);

        System.out.println("====迭代器====");
        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            Object next = iterator.next();
            System.out.println(next);
        }
        System.out.println("====增强for====");
        for (Object o :set) {
            System.out.println(o);
        }


    }
}
